<?php
/**
 * Created by PhpStorm.
 * User: 仙女大人
 * Date: 2019/6/5
 * Time: 16:49
 */

namespace app\admin\model;
use think\Model;
use think\Db;

class Auth extends Model
{
    // 设置数据表（不含前缀）
    protected $name = 'user';

    // 定义多对多关联
    public function authGroup()
    {
        return $this->belongsToMany('AuthGroup','auth_group_access','group_id','uid');
    }

    public function region($region){
        $query = Db::table('think_auth_group')->alias('x');
        $query->field("x.id,x.title");
        $join = [
            ['auth_group_access e','x.id = e.group_id','LEFT'],
        ];
        $name = $query->join($join)->where(["x.id"=>$region])->select();
        return $name;
    }
}